var fs = require('fs')
var buffer = Buffer.from('Hello Node')
console.log(buffer) // <Buffer 48 65 6c 6c 6f 20 4e 6f 64 65>
var s = buffer.toString('utf-8', 0, 5)
console.log(s) // Hello



var rs = fs.createReadStream('./test.txt', {highWaterMark: 10})
var data = ''
rs.on('data', chunk => {
  console.log(chunk.toString())
  data += chunk
})
rs.on('end', () => console.log('data', data))

var rs2 = fs.createReadStream('./test.txt', {highWaterMark: 10})
var data1 = []
rs2.on('data', chunk => {
  data1.push(chunk)
})
rs2.on('end', () => {
  var b = Buffer.concat(data1)
  console.log(b.toString())
})